how to convert dataframe to list in python

42

how to convert a list into a dataframe in python -

from pandas import DataFrame

People_List = ['Jon','Mark','Maria','Jill','Jack']

df = DataFrame (People_List,columns=['First_Name'])
print (df)

how to convert dataframe to list in python -

df.values.tolist()

List to Dataframe -

# import pandas as pd 

import pandas as pd 
# list of strings 
lst = ['fav', 'tutor', 'coding', 'skills']
# Calling DataFrame constructor on list 
df = pd.DataFrame(lst) 
print(df) 

convert list to dataframe -

L = ['Thanks You', 'Its fine no problem', 'Are you sure']

#create new df 
df = pd.DataFrame({'col':L})
print (df)

                   col
0           Thanks You
1  Its fine no problem
2         Are you sure

Comments

Submit
0 Comments